﻿///* 
// * author: www.cnblogs.com/luminji
// * date  : 2012/02/01
// */
//using System.Collections.Generic;
//using System.Web.Mvc;
//using Luminji.Core.Web.Cookie;
//using Luminji.Core.Web.Mockes;
//using Luminji.Exam.Model.Users;
//using Luminji.ExamWeb.Controllers;
//using Luminji.ExamWeb.Models;
//using Microsoft.VisualStudio.TestTools.UnitTesting;
//using Moq;

//namespace Luminji.ExamWeb.Tests.Web.Controllers.Account
//{
//    [TestClass]
//    public class AccountControllerTest
//    {
//        protected List<LogOnModel> _users = new List<LogOnModel>();
//        protected Mock<IExamUserService> _mock = new Mock<IExamUserService>();
//        protected AccountController _controller;

//        [TestInitialize()]
//        public void AccountInitialize()
//        {
//            var re1 = new List<ExamUser>() { new ExamUser() { CurrentUserName = "abc", UserKey = "123" } };
//            _mock.Setup(service => service.FindAll("abc")).Returns(re1);
//            _mock.Setup(service => service.FindAll("abc123")).Returns(new List<ExamUser>());
//            //_controller.Request = 
//            _controller = new AccountController(_mock.Object);
//            _controller.SetFakeControllerContext();
//        }
        
//        [TestMethod]
//        public void ShouldRedirectToLoginIfCookieNull()
//        {
//            RedirectToRouteResult re = _controller.Index() as RedirectToRouteResult;
//            Assert.AreEqual("Account", re.RouteValues["controller"]);
//            Assert.AreEqual("LogOn", re.RouteValues["action"]);
//        }

//        [TestMethod]
//        public void ShouldStayInIndexIfHaveCookie()
//        {
//            LogOnModel model = 
//                new LogOnModel()
//                    {
//                        UserName = "abc",
//                        Password = "123",
//                        RememberMe = true
//                    };
//            CookieHelper.SetCookieValue<LogOnModel>(_controller.Response, "LogOnModel", model);
//            var re0 = _controller.Index();
//            RedirectToRouteResult re = _controller.Index() as RedirectToRouteResult;
            
//            Assert.AreEqual("Account", re.RouteValues["controller"]);
//            Assert.AreEqual("Index", re.RouteValues["action"]);
//        }
//    }
//}
